Skip to content

[client-v2] Fix reading Dynamic values that hold an unnamed tuple - #3385

Open
Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/dynamic-tuple-read
Open

Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/dynamic-tuple-read

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

A Dynamic value whose type has a tuple without element names, such as Tuple(Int32, String) or Array(Tuple(Int32, String)), could not be read. The tag of such a tuple is 0x1F, which is also the tag of ClickHouseDataType.Tuple. readDynamicData found it in binTag2Type and returned a bare Tuple column without reading the element count and the element types. The rest of the row was then read from the wrong bytes. The read failed with Missing nested data type or Unsupported data type with tag 97, or it returned wrong values or no rows.

Now 0x1F goes to the tuple branch that already reads named tuples. The value is an Object[], the same as for a named tuple. Values that already worked are read as before.

Closes #3384

Checklist


Note

Medium Risk
Touches core binary deserialization for Dynamic types; wrong logic could misdecode rows, but the change is narrow and heavily tested.

Overview
Fixes client-v2 / jdbc-v2 decoding when a Dynamic column’s runtime type includes unnamed tuples (e.g. Tuple(Int32, String), nested tuples, arrays/maps/variants of those types).

readDynamicData no longer treats binary tag 0x1F as a plain Tuple type from binTag2Type and stopping early. It now routes Tuple-tagged encodings into the same branch as named tuples, so element count and nested type encodings are consumed before values are read—keeping the stream aligned with the rest of the row.

Values decode as Object[], consistent with named tuples. Unit and integration tests cover nested unnamed tuples, nullable fields, arrays, maps, variants, and JSON; changelog #3384 documents the prior mis-read symptoms (wrong bytes, missing nested types, EOF).

Reviewed by Cursor Bugbot for commit a989f2d. Bugbot is set up for automated code reviews on this repo. Configure here.

The binary type encoding of a tuple without element names starts with
tag 0x1F, which is also the tag of ClickHouseDataType.Tuple.
readDynamicData found it in binTag2Type and used the default branch of
the switch. That branch returned a bare Tuple column and left the
element count and the element types in the stream, so the rest of the
row was read from the wrong bytes.

Send 0x1F to the tuple branch that already reads the named tuple tag
0x20. The value is now an Object[], the same as for a named tuple.

Closes ClickHouse#3384
@Indian-boult
Indian-boult requested review from a team and mzitnik as code owners November 18, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client-v2] Reading a Dynamic value that holds a tuple without element names fails or returns wrong data

1 participant